{include file=$header_start}
{strip}
<link rel="stylesheet" type="text/css" href="{$siteroot}/templates/default/style/dashboard.css">
<script src="{$siteroot}/includes/js/myaccount.js" type="text/javascript"></script>
<script src="{$siteroot}/includes/js/admin/ajax.js" type="text/javascript" ></script>

{/strip}
{literal}
<script type="text/javascript">

function getSelectedCheckbox(buttonGroup) {
   // Go through all the check boxes. return an array of all the ones
   // that are selected (their position numbers). if no boxes were checked,
   // returned array will be empty (length will be zero)
   var retArr = new Array();
   var lastElement = 0;
   if (buttonGroup[0]) { // if the button group is an array (one check box is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].selected) {
            retArr.length = lastElement;
            retArr[lastElement] = i;
            lastElement++;
         }
      }
   } else { // There is only one check box (it's not an array)
      if (buttonGroup.selected) { // if the one check box is checked
         retArr.length = lastElement;
         retArr[lastElement] = 0; // return zero as the only array value
      }
   }
   return retArr;
} // Ends the "getSelectedCheckbox" function
  
  function getSelectedCheckboxValue(buttonGroup) {
   // return an array of values selected in the check box group. if no boxes
   // were checked, returned array will be empty (length will be zero)
   var retArr = new Array(); // set up empty array for the return values
   var selectedItems = getSelectedCheckbox(buttonGroup);
   if (selectedItems.length != 0) { // if there was something selected
      retArr.length = selectedItems.length;
      for (var i=0; i<selectedItems.length; i++) {
         if (buttonGroup[selectedItems[i]]) { // Make sure it's an array
            retArr[i] = buttonGroup[selectedItems[i]].value;
         } else { // It's not an array (there's just one check box and it's selected)
            retArr[i] = buttonGroup.value;// return that value
         }
      }
   }
   return retArr;
}
function in_array(array, id) {
    for(var i=0;i<array.length;i++) {
		
        if(array[i] === id) {
            return true;
        }
    }
    return false;
}


function showJobType(){
//alert(document.getElementById("catname").value);
//var chk_arr = new Array();
//var checkBoxArr = getSelectedCheckboxValue(document.frmMngProfile.catname);	
//alert(checkBoxArr);
//document.getElementById('hidediv').style.display='block';
	
	var namecat = document.getElementsByName("catname[]");
	var newstr='';
	var myArray=new Array(); 
	for(var i=0; i< namecat.length;i++)
	{
		var str ='';
		str = namecat.item(i).value;
		
		if(str !='')
		{
			
			if(in_array(myArray, str))
			{
				i=i+1;
				document.getElementById("catname_"+i).value='';
				alert("Please select different category!");
				return false;				
			}
			else
			{
				myArray[i] =str;
				if(newstr == '')
				{
					newstr=str;	
				}
				else
				{
					newstr = newstr+','+str;	
				}
			}
			
		}
	}
//	alert(newstr);
	//return false;
//		var fl = 0;
//	var chk_arr = new Array();
//	var checkBoxArr = getSelectedCheckboxValue(document.frmTradesmanAdd.catname);	
	//alert(checkBoxArr);
	//document.getElementById('hidediv').style.display='block';
	ajax.sendrequest("GET",SITEROOT + "/modules/register/show_jobtype.php",{jid:newstr},"","isJobType");

	
	ajax.sendrequest("GET",SITEROOT + "/modules/register/show_jobtype.php",{jid:checkBoxArr},"","isJobType");
}

</script>
<script type="text/javascript"><!--
function numbersonly(e)
{		

	var unicode=e.charCode? e.charCode : e.keyCode;		
	//alert(unicode)
	if (unicode!=8 && unicode !=9  &&  unicode !=39 &&  unicode != 46 &&  unicode !=  34 )
	{ 	
		//if the key isn't the backspace,Tab key (which we should allow)
		if (unicode<48||unicode>57) //if not a number
			return false; //disable key press
	}
}

jQuery(document).ready(function(){
	
	jQuery("#btn_addmore").click(function(){
		window.location.href=SITEROOT + '/myaccount/serviceslist/'		
	});	
});

</script>
<script type="text/javascript" >
function testfunction()
{
	document.getElementById("submitbtn").style.display ='none';	
}
</script>

{/literal}

{include file=$header_end}

<body></body>
   <!-- MIDDLE CONTAIN GOES HERE -->
<section class="middle_portion">
	<section class="inner_head">Dashboard</section>
    <section class="inner_containstart">
    	<!-- dashboard Left Content Start -->
        	{include file=$cms_left_content}
        <!-- dashboard Left Content End -->
        <!-- dashboard Right Content Start -->
        	<section class="dash_right">     
            
            {if $msg}<span style="padding:10px">{$msg}</span>{/if}
            	<section class="title_box">
                   <span class="lF"> <h4>My Service & location</h4></span> <!--<span class="rF" style="padding-top:10px;" >"Want to add more Trade Category? Update your Trade Category and Job Type – <a href="{$siteroot}/myaccount/mytradecategory/">click here</a>" </span>-->
         
                    <section class="clear"></section>
                </section>
                <form method="post" action="" name="frmMngProfile" id="frmMngProfile" enctype="multipart/form-data">
                 <input type="hidden" name="hidden_userid" id="hidden_userid" value="{$userDetArray.id}" />
                 <input type="hidden" name="latlongArray" id="latlongArray" value="{$latlongArray}" />
    			<input type="hidden" id="radiusdata" name="radiusdata" value="" />         
				<input type="hidden" id="centerpt" name="centerpt" value="" />
                
                
                <section class="profile_wrapp">
                  <!--  <dl>
                        <dt><label>Trade Category:  </label></dt>
                        <dd>
                        	<select class="select" name="catname" id="catname" onChange="showJobType(this.value);">
                                <option value="">Select trade category</option>
                                {section name=i loop=$newtradecategoryArray}
                                    <option value="{$newtradecategoryArray[i].id}" {if $userDetArray.tradeid eq $newtradecategoryArray[i].id} selected="selected" {/if}>{$newtradecategoryArray[i].trade_category}</option>
                                {/section} 
                            </select>
                        </dd>
                        <section class="clear"></section>
                    </dl>-->
                    
                    <input type="hidden" value="{$remainingcnttradeid}" id="remainingcnttradeid" name="remainingcnttradeid" />
                    <input type="hidden" value="{$cnttradeid}" id="feeratedivValue" name="feeratedivValue" />
                    <input type="hidden" name="feerateDiv" id="feerateDiv"  />
                  	<div class="usercats" style="margin:20px 0 50px;">
                    	<table cellpadding="0" cellspacing="0" width="100%" class="table_viewbox">
                        	<thead>
                            	<tr>
	                                <th width="20">#</th>
                                    <th>Category Name</th>
                                    <th>Job Type</th>
                                    <th width="100">Expiry time</th>
                                </tr>
                            </thead>
                            <tbody>
                            	{section name=i loop=$usercats}
                                    <tr class="{$usercats[i].class}">
                                    	<td>{$usercats[i].ind}</td>
                                    	<td>{$usercats[i].trade_category}</td>
                                        <td>{$usercats[i].parent_name}</td>
                                    	<td>{$usercats[i].expired}</td>
                                    </tr>
                                {/section}
                            </tbody>
                        </table>
                        
                        <p>
                        	<input type="button" id="btn_addmore" value="Add more" class="org_btn admore">
                        </p>
                    </div>
                  
                  
                  
                    <section class="clear"></section>
                    <dl>
                        <dt><label>Postal Code : </label></dt>
                        <dd><input type="text" class="input" name="googlesearch" id="googlesearch" value="{$userDetArray.workarea}"  />
                        {* onKeyPress="return numbersonly(event);" testfunction*}
							<div id="google_address_error" ></div>
                        </dd>
                        <section class="clear"></section>
                    </dl>
                    <dl>
                        <dt><label>Select one of Multiple States : </label></dt>
                        <dd>						
						<select class="select" name="state_id[]" id="state_id" style="width:160px; height:150px; float:left" multiple="multiple" >
						{section name=i loop=$stateArray}
						<option value="{$stateArray[i].state_id}"  {if $stateArray[i].selected eq 1} selected="selected"  {/if}>{$stateArray[i].state_name}</option>
						{/section}
						</select>
	                       	   
                        <section class="clear"></section>
                        </dd>
                        <section class="clear"></section>
                        
                    </dl>
                    <section class="clear"></section>
                  <div id="distance"></div>
              
                <div id="submitbtn" >
                <section class="bt_save_wrapp" style="margin-bottom:20px;">
                    	<input type="submit" value="Save" name="save_btn" id="save_btn" class="bt_save"/>
                        <input type="button" value="Cancel" name="cancel_btn" id="cancel_btn" class="bt_save" {if $smarty.session.user_type eq '3'} onclick="window.location.href='{$siteroot}/myaccount/'" {else} onclick="window.location.href='{$siteroot}/profile/{$userDetArray.newcomapnyname}'" {/if}/>
                </section>
                </div>    
                </section>                
                </form> 
            </section>
        <!-- dashboard Right Content End -->
        	<section class="clear"></section>
    </section>
</section>
{include file=$footer}
